package com.lanmao.emc.strategy;

import com.lanmao.emc.enums.UpgradeType;
import org.springframework.stereotype.Component;

import java.util.EnumMap;
import java.util.Map;

/**
 * 描述：
 *
 * @author lanmao
 * @since 2024年11月11日 20:42
 */
@Component
public class UpgradeStrategyFactory {
    protected static final Map<UpgradeType, UpgradeStrategy> UPGRADE_STRATEGY_MAP = new EnumMap<>(UpgradeType.class);

    public void upgradeIndex(UpgradeType type) {
        UPGRADE_STRATEGY_MAP.get(type).upgradeIndex();
    }

    public void rollback(UpgradeType type, String index, String version) {
        UPGRADE_STRATEGY_MAP.get(type).rollback(index, version);
    }

    public void initTable(UpgradeType type) {
        UPGRADE_STRATEGY_MAP.get(type).initTable();
    }
}